#include <iostream>
#include <cstdio>
#include <cstring>
typedef long long ll;
const int MOD=1e9+7;
using namespace std;
int pos[100005];
ll dp[100005];
int position(int a) {
    if (a<0) return 0;
    else return pos[a];
}
int main() {
    int n;
    cin>>n;
    int a[n+1];
    for (int i=1; i<=n; i++) scanf("%d", &a[i]);
    memset(pos, 0, sizeof(pos));
    dp[0]=1;
    for (int i=1; i<=n; i++) {
        dp[i]=dp[i-1]*2%MOD;
        dp[i]=(dp[i]-dp[position(a[i])-1])%MOD;
        if (dp[i]<0) dp[i]+=MOD;
        pos[a[i]]=i;
    }
//    for (int i=0; i<=n; i++) cout<<dp[i]<<' ';
//    cout<<endl;
    cout<<dp[n]-1<<endl;
    return 0;
}
